use anyhow::Result;
use std::path::Path;
use teloxide::adaptors::{DefaultParseMode, Throttle};

pub type Bot = Throttle<DefaultParseMode<teloxide::Bot>>;

use serde::Deserialize;
#[derive(Debug, Deserialize, Clone)]
pub struct Config {
    pub bot_token: String,
    pub postgres_url: String,
    pub postgres_user: String,
    pub postgres_db: String,
    pub proxy: String,
    pub rules_file: String,
    pub mercury_path: String,
    pub readability_path: String,
}
use tokio::{fs::File, io::AsyncReadExt};

impl Config {
    pub async fn load(file_path: impl AsRef<Path>) -> Result<Self> {
        let mut file = File::open(file_path).await?;
        let mut data = String::new();
        file.read_to_string(&mut data).await?;
        let data: Config = toml::from_str(&data)?;
        Ok(data)
    }
}
